{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.image.AxesImage at 0x7f402e0fec88>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAUoAAAD8CAYAAAARze3ZAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+j8jraAAAgAElEQVR4nO3deXwU9f0/8Nd7j2yOzZ0QkhByQQIBTIAQEkSOFr4aqkLFiqVWRIR6gaBY4autVsGLfrUeWFRKgVYK/X1ti1UU/SEUDw65IZwJJEI4wpmE3Nn9fP/YybhLdrMh2dmZzb6fj0cemc9nZmfemYQ3n5n5fOZDQggwxhhzTad2AIwxpnWcKBljzA1OlIwx5gYnSsYYc4MTJWOMucGJkjHG3FAsURLRLUR0hIiKiWieUsdhjDGlkRL9KIlID+AogLEATgH4DsDPhRAHPX4wxhhTmFItyjwAxUKI40KIRgCrAYxX6FiMMaYog0L7TQRw0q58CsBQVxsTEQ8PYn7PYDCgZ8+ecjkoKAiBgYFOt21ubkZ1dbVcPnv2LGpraxWPsYu7IISIdbZCqUTpFhHNADBDreMzpiVGoxEffPCBXDYYDMjOzkZaWprT7S9duoSvvvoKjY2Nct3cuXPx/fffKx5rF1bmaoVSl97lAJLsyj2kOpkQ4j0hRK4QIlehGBjzSUajEVlZWS6TJABERUUhPz8fQUFBcl3Pnj2h1+u9EaLfUSpRfgegNxGlElEAgLsBfKTQsRjrUmJiYpCZmel2u7i4OPTq1Usuz5o1CyEhIUqG5rcUSZRCiGYAjwJYD+AQgL8LIYqUOBZjXcEtt9zSoc9FRkYiPDzcw9Gwayl2j1IIsQ7AOqX2z1hXMnny5A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DSAeQAOAPgf9QNxzkiMgP4EMBsIUSV/TqtnmsnMWv+XAshLEKIHAA9YGvV9vHm8dVOlOUAkuzKPaQ6zRFClEvfKwD8E7Zf1rmWyyfpe4V6EbbJVZyaPf9CiHPSPw4rgPfxwyWfZmImIiNsCecDIcQ/pGpNn2tnMfvCuW4hhLgCYCOAAthuX7RMZ2Mfmxy3tD4cwMXOHFftRPkdgN7S06sA2G68fqRyTK0QUQgRhbYsA/gvAAdgi7VljoIpANaqE6FbruL8CMC90hPZfACVdpeNqrrm/t1PYTvfgC3mu6Unm6kAegPw+qQy0j2vPwE4JISwnyRes+faVcw+cK5jiShCWg4CMBa2+6sbAdwpbXbtuW75HdwJ4Eupdd9x3n6C5eSJ1jjYnr6VAHha7XhcxJgG29O/vQCKWuKE7b7HBgDHAPx/AFEaiPVvsF0+NcF232aaqzhhe5q4WDr3+wHkaijmv0gx7ZP+8OPttn9aivkIgEKVYh4O22X1PgB7pK9xWj7XbcSs9XN9A4DdUnwHAPxWqk+DLXEXA/h/AExSfaBULpbWp3U2Bh6Zwxhjbqh96c0YY5rHiZIxxtzgRMkYY25womSMMTc4UTLGmBucKBljzA1OlIwx5gYnSsYYc+P/ANXQuZO6NBaoAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "img = plt.imread(\"./gt000842.png\")\n",
    "plt.imshow(img)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0, 1, 1])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "x = np.array([1,2,3])\n",
    "array = np.where(x>1,1,0)\n",
    "array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [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/z7PTYD2AfgTQBpLsi6Ev7Np3L499vcEywn/EcTn7WW/R4A2S7KvMLKtNv6w28b8PpHrMyfAhhvKPMN8G9W7wZQYA05bl7WdWR2+7LOAvC/Vr4iAL+wxneFv7iLAawB4LPGJ1nPi63pXUPNwE/mEBHZML3pTUTkeixKIiIbLEoiIhssSiIiGyxKIiIbLEoiIhssSiIiGyxKIiIb/w+skelZNMVi1QAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "img = np.where(img>0,255,0);\n",
    "plt.imshow(img)\n",
    "plt.savefig(\"img.png\") "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[  0  50 170 255]\n",
      "[  0. 255.]\n"
     ]
    }
   ],
   "source": [
    "from PIL import Image \n",
    "import numpy as np \n",
    "from collections import  Counter\n",
    "I = Image.open(\"./gt000842.png\").convert('L') \n",
    "\n",
    "I_array = np.array(I) \n",
    "print(np.unique(I_array))\n",
    "I_array = np.where(I_array==255.0,255.0,0.0)\n",
    "print(np.unique(I_array))\n",
    "\n",
    "I_after = Image.fromarray(I_array)\n",
    "I_after.show() \n",
    "I_after.convert(\"L\").save('./save.png') \n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "img = plt.imread(\"./gt000842.png\")\n",
    "plt.imshow(img)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 给图片添加半透明的掩码mask\n",
    "# refer:https://blog.csdn.net/weixin_41735859/article/details/103758249\n",
    "#\n",
    "\n",
    "import numpy as np\n",
    "import os\n",
    "import cv2\n",
    "\n",
    "def put_mask(box_list, img_path, output_fold):\n",
    "\n",
    "    # 1.读取图片\n",
    "    image = cv2.imread(img_path)\n",
    "    # 2.获取标签\n",
    "    # 标签格式　bbox = [xl, yl, xr, yr]\n",
    "#     bbox1 = [72,41,208,330]\n",
    "#     bbox2 = [100,80,248,334]\n",
    "\n",
    "    # 3.画出mask\n",
    "    zeros_mask = np.zeros((image.shape), dtype=np.uint8)\n",
    "    \n",
    "    for box in box_list[:2]:\n",
    "        # 左上角坐标以及右下角的坐标为小数导致的类型报错，使用int()整数化\n",
    "        # cv2.rectangle 函数要求image的形状应该为（通道，长，宽）\n",
    "        zeros_mask = cv2.rectangle(zeros_mask, (int(box[0]), int(box[2])), (int(box[1]), int(box[3])),\n",
    "                    color=(0,0,255), thickness=-1 ) #thickness=-1 表示矩形框内颜色填充\n",
    "\n",
    "\n",
    "    try:\n",
    "    \t# alpha 为第一张图片的透明度\n",
    "        alpha = 1\n",
    "        # beta 为第二张图片的透明度\n",
    "        beta = 0.5\n",
    "        gamma = 0\n",
    "        # cv2.addWeighted 将原始图片与 mask 融合\n",
    "        mask_img = cv2.addWeighted(image, alpha, zeros_mask, beta, gamma)\n",
    "        cv2.imwrite(os.path.join(output_fold,'mask_img.jpg'), mask_img)\n",
    "    except:\n",
    "        print('异常')\n",
    "\n",
    "box_list = [[1.0427e+02, 5.7943e+02, 2.4613e+02, 6.6483e+02], [4.5725e+02, 4.9376e+02, 5.3914e+02, 6.2981e+02], [1.2557e+02, 8.4333e+02, 2.0418e+02, 9.1257e+02], [3.9162e+02, 7.9248e+02, 4.6815e+02, 8.8164e+02], [0.0000e+00, 9.1066e+02, 1.0515e+02, 9.9017e+02], [4.6091e+02, 3.4375e+02, 5.8946e+02, 4.5174e+02], [2.3101e+02, 0.0000e+00, 3.2247e+02, 5.9151e+01], [7.2992e+02, 8.8570e+02, 8.2925e+02, 9.7589e+02], [1.1487e+02, 3.7226e+01, 2.1751e+02, 1.0650e+02], [2.2211e+00, 1.2452e+00, 1.0155e+02, 7.1553e+01], [5.2935e+02, 8.6054e+02, 6.4470e+02, 9.8685e+02], [4.2968e+02, 6.3288e+01, 5.3150e+02, 1.4061e+02], [9.4410e+02, 6.4882e+02, 1.0214e+03, 7.4549e+02], [4.7521e+02, 1.0397e+01, 5.5017e+02, 8.3184e+01], [9.3185e+02, 7.7386e+02, 1.0167e+03, 8.5850e+02], [9.1018e+02, 8.8307e+02, 9.7774e+02, 9.7692e+02], [9.5131e+01, 1.9281e-01, 2.1783e+02, 5.0106e+01], [7.2940e+02, 1.5033e+02, 8.1579e+02, 2.4286e+02], [7.8665e+02, 7.2762e+02, 8.8414e+02, 8.0354e+02], [4.4858e+02, 9.6802e+02, 5.4925e+02, 1.0237e+03], [8.8580e+02, 4.4923e+01, 9.9710e+02, 1.4139e+02], [4.3547e+02, 4.7873e+02, 4.9681e+02, 5.5080e+02], [9.8538e+02, 5.8510e+02, 1.0238e+03, 6.7079e+02], [1.1369e+00, 7.3472e+02, 8.7314e+01, 8.4368e+02], [2.4190e+02, 1.0022e+03, 2.9298e+02, 1.0238e+03], [4.8324e-01, 2.7038e+02, 4.1717e+01, 3.3946e+02], [1.8055e+02, 1.0028e+03, 2.2342e+02, 1.0228e+03], [4.4025e+02, 4.8327e+02, 5.2188e+02, 5.7702e+02], [1.0025e+03, 4.9892e+02, 1.0240e+03, 5.5517e+02], [0.0000e+00, 8.0877e+02, 3.8395e+01, 8.5148e+02], [6.4393e-01, 7.4211e+02, 4.1206e+01, 8.3025e+02], [2.3878e+02, 9.8990e+02, 3.0261e+02, 1.0217e+03], [4.7430e+02, 5.8276e+00, 5.2676e+02, 6.1360e+01], [1.3011e+02, 1.0109e+03, 2.2566e+02, 1.0222e+03], [1.0058e+03, 6.5870e+02, 1.0240e+03, 7.3820e+02], [7.3086e+01, 2.1276e+00, 1.0453e+02, 5.7440e+01], [5.2511e+01, 7.0344e-02, 1.9764e+02, 6.7981e+01], [2.5031e+01, 0.0000e+00, 1.0436e+02, 3.9419e+01]]\n",
    "put_mask(box_list, img_path = '2fd875eaa.jpg', output_fold='./')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "## 通过点\n",
    "\n",
    "import json\n",
    "import numpy as np\n",
    "import os\n",
    "from PIL import Image\n",
    "import matplotlib.pyplot as plt\n",
    "import cv2\n",
    "\n",
    "def process_points(im_path,points,output_path):\n",
    "\n",
    "        # 获取坐标信息,\n",
    "        points = np.array([points], dtype=np.int32)\n",
    "\n",
    "        # 读取图片名\n",
    "        img = cv2.imread(im_path)\n",
    "\n",
    "        # # 绘制mask\n",
    "        # zeros = np.zeros((img.shape), dtype=np.uint8)\n",
    "        # 原本thickness = -1表示内部填充,这里不知道为什么会报错,只好不填充了\n",
    "        cv2.polylines(img, points, isClosed=True, thickness=5, color=(144, 238, 144))\n",
    "\n",
    "        cv2.imwrite(os.path.join(output_path, 'handsome.jpg'), img)\n",
    "\n",
    "# 这是我用labelme画的不规则点坐标\n",
    "points = [[14.222222222222229, 1076.111111111111], [133.1111111111111, 849.4444444444445],\n",
    "          [240.8888888888889, 776.1111111111111], [252.0, 737.2222222222222],\n",
    "          [253.1111111111111, 619.4444444444445], [298.66666666666663, 569.4444444444445],\n",
    "          [298.66666666666663, 530.5555555555555], [270.8888888888889, 483.88888888888886],\n",
    "          [247.55555555555554, 355.0], [242.0, 221.66666666666666], [282.0, 188.33333333333331],\n",
    "          [332.0, 206.11111111111111], [388.66666666666663, 243.88888888888889],\n",
    "          [433.1111111111111, 182.77777777777777], [457.55555555555554, 93.88888888888889],\n",
    "          [480.8888888888889, 2.7777777777777777], [512.0, 6.111111111111111],\n",
    "          [536.4444444444445, 82.77777777777777], [596.4444444444445, 168.33333333333334],\n",
    "          [683.1111111111111, 171.66666666666666], [746.4444444444443, 227.22222222222223],\n",
    "          [794.2222222222222, 296.1111111111111], [850.8888888888889, 359.44444444444446],\n",
    "          [837.5555555555554, 413.88888888888886], [840.8888888888889, 465.0], [792.0, 519.4444444444445],\n",
    "          [867.5555555555554, 686.1111111111111], [899.7777777777778, 1010.5555555555555],\n",
    "          [879.7777777777778, 1076.111111111111]]\n",
    "\n",
    "process_points(im_path='./zhong.jpg',points=points,output_path='./')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(512, 512, 3)\n"
     ]
    }
   ],
   "source": [
    "# 通过二值图，给图片添加半透明的掩码mask\n",
    "# refer:https://blog.csdn.net/weixin_41735859/article/details/103758249\n",
    "#\n",
    "\n",
    "import numpy as np\n",
    "import os\n",
    "import cv2\n",
    "\n",
    "def put_seg_mask(binary_img_path, img_path, output_fold):\n",
    "\n",
    "    # 1.读取图片\n",
    "    binary_image = cv2.imread(binary_img_path)\n",
    "    binary_image = np.where(binary_image>(binary_image.max()+binary_image.min())/2,255,0);\n",
    "#     binary_image[::0] = 0\n",
    "#     print(binary_image[:,:,0], binary_image[:,:,0].shape)\n",
    "    binary_image[:,:,0] = 0\n",
    "    binary_image[:,:,1] = 0\n",
    "    cv2.imwrite(os.path.join(output_fold,'binary_image.jpg'), binary_image)\n",
    "    image = cv2.imread(img_path)\n",
    "    image = cv2.resize(image, (binary_image.shape[0], binary_image.shape[1]))\n",
    "    \n",
    "    # 2.获取标签\n",
    "    # 标签格式　bbox = [xl, yl, xr, yr]\n",
    "#     bbox1 = [72,41,208,330]\n",
    "#     bbox2 = [100,80,248,334]\n",
    "\n",
    "    # 3.画出mask\n",
    "    zeros_mask = np.zeros((image.shape), dtype=np.uint8)\n",
    "    zeros_mask[::1] = binary_image[::1]\n",
    "    print(zeros_mask.shape)\n",
    "\n",
    "    try:\n",
    "    \t# alpha 为第一张图片的透明度\n",
    "        alpha = 1\n",
    "        # beta 为第二张图片的透明度\n",
    "        beta = 0.5\n",
    "        gamma = 0\n",
    "        # cv2.addWeighted 将原始图片与 mask 融合\n",
    "        mask_img = cv2.addWeighted(image, alpha, zeros_mask, beta, gamma)\n",
    "        cv2.imwrite(os.path.join(output_fold,'mask_img.jpg'), mask_img)\n",
    "    except:\n",
    "        print('异常')\n",
    "\n",
    "put_seg_mask(binary_img_path = 'in001700_gray.jpg', img_path = 'in001700.jpg', output_fold='./')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
